* Clean up
clear all

/* Set working directory: please set your own
cd "~/Dropbox/JOP third submission/JOP replication/"
*/


* Open dataset
use 01_data/whole_spain.dta, clear

* Run analyses

* Model 1
reghdfe pp_voteshare post##ep##ciutadella if period > 1, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
est store twoperiods_pp_ddd

* Model 2
reghdfe pp_voteshare post##ep##ciutadella, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
est store prepost_pp_ddd

* Model 3
reghdfe pp_voteshare post##ep##ciutadella i.period, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
est store threeperiods_pp_ddd

* Placebo
reghdfe pp_voteshare_lag post##ep##ciutadella, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
est store placebo_pp_ddd

* Make table
esttab twoperiods_pp_ddd prepost_pp_ddd threeperiods_pp_ddd placebo_pp_ddd using 03_tables/table4.tex, tex se replace mtitles ("2014-2019" "2009-2019" "2009-2019" "Placebo lagged outcome")  keep (1.post 1.post#1.ep 1.post#1.ciutadella 1.post#1.ep#1.ciutadella 2.period) coeflabels (1.post "2019 election" 1.post#1.ep "EP election in 2019" 1.post#1.ciutadella "Ciutadella in 2019" 1.post#1.ep#1.ciutadella "EP 2019 x Ciutadella" 2.period "2014-2015 election") star(* 0.10 ** 0.05 *** 0.01) addnotes("All models include voting station * election type fixed effects" "Standard errors are clustered by voting station * election type") 
